﻿; (function () {
    $(function () {
        page.init();
       
    });
    var _bt = window.BT;
    var gridFormatter = {
        "showDetail": function (column, row) {
            return "<a target='_blank' href='http://app.sipo.gov.cn:8080/searchfee/searchfee_action.jsp?sqh=" + row['PatNum'] + "'>查看</a>";
        },
        "link": function (column, row) {
            return '<div class="ui-pg-div" >'
                      + '<a onclick="showdialog(this)" class="ui-icon icon-envelope blue" title="已通知"></a>'
                      + '<a onclick="showdialog(this)" class="ui-icon icon-envelope-alt blue" title="未通知"></a>'
                  + '</div>';
        }
    };
    var page = {
        init: function () {
            this.event.init();
        },
        ajax: _bt.ajax,
        dialog: _bt.dialog,
        event: {},
        config: {
            payGrid: {
                id: '#table-pay-grid'
                ,url: '/PatentMonitor/GetYearPayList'
                , formatters: gridFormatter
                 , events: [{
                     name: 'loaded',
                     event: payTotalShow
                 }]
            },
            latePayGrid: {
                id: '#table-late-pay-grid'
                ,url: '/PatentMonitor/GetYearLatePayList'
                , formatters: gridFormatter
                ,events: [{
                    name: 'loaded',
                    event:latePayTotalShow
                 }]
            },
            contactGrid:{
                id:'#table-contact'
               ,url: '/PatentMonitor/GetContactList'
               ,formatters: gridFormatter
               ,events: [{
                     name: 'loaded',
                     event: contactTotalShow
                 }]
            }
        }
    };
    //即将过年费缴纳期
    page.payGrid = new _bt.BGrid(page.config.payGrid, null, true);
    //即将过年费滞纳期
    page.latePayGrid = new _bt.BGrid(page.config.latePayGrid, null, true);
    //通知记录
    page.contactGrid = new _bt.BGrid(page.config.contactGrid, null, true);

    page.event.init = function () {
        //缴纳查询
        $('#btn-pay-search').on('click', paySearch);
        //滞纳查询
        $('#btn-late-pay-search').on('click', latePaySearch);
        //通知记录查询
        $('#btn-contact-search').on('click', contactSearch);
    }


    //即将过年费缴纳期
    function paySearch() {
        var obj = $('#form-pay').serializeObject();
        page.payGrid.reload(obj);
    }
    //即将过年费滞纳期
    function latePaySearch() {
        var obj = $('#form-late-pay').serializeObject();
        page.latePayGrid.reload(obj);
    }
    //通知记录查询
    function contactSearch() {
        var obj = $('#form-contact').serializeObject();
        page.contactGrid.reload(obj);
    }
    //缴纳总数
    function payTotalShow() {
        var total = page.payGrid.getCount();
        $('#span-pay-total').text(total);
    }
    //滞纳总数
    function latePayTotalShow() {
        var total = page.latePayGrid.getCount();
        $('#span-late-pay-total').text(total);
    }
    //通知总数
    function contactTotalShow() {
        var total = page.contactGrid.getCount();
        $('#span-contact-total').text(total);
    }
})();